package com.itheima.a05myobjectstream;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class ObjectStreamDemo4 {
    public static void main(String[] args) throws IOException {
        //一次性序列化多个对象

        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("myio\\stu.txt"));

        //创建集合存多个对象
        ArrayList<Student> list=new ArrayList<>();
        list.add(new Student("zhangsan", 18));
        list.add(new Student("zhang", 19));
        list.add(new Student("san", 20));

        oos.writeObject(list);

        oos.close();
    }
}
